@import '@/styles/variables.less';
@import '@/styles/mixins.less';

.file-selector {
  width: 100%;
  border: 1px solid @gray-200;
  border-radius: @border-radius-lg;
  background: white;

  &__header {
    .flex-between();
    align-items: center;
    padding: @spacing-md @spacing-lg;
    border-bottom: 1px solid @gray-200;
    gap: @spacing-md;
  }

  &__search {
    flex: 1;
  }

  &__search-input {
    width: 100%;
    padding: @spacing-sm @spacing-md;
    border: 1px solid @gray-300;
    border-radius: @border-radius;
    font-size: @font-size-sm;
    transition: border-color @transition-fast;

    &:focus {
      outline: none;
      border-color: @primary-500;
      box-shadow: 0 0 0 3px @primary-100;
    }

    &::placeholder {
      color: @gray-400;
    }
  }

  &__select-all {
    padding: @spacing-xs @spacing-sm;
    border: 1px solid @primary-300;
    background: transparent;
    color: @primary-600;
    border-radius: @border-radius;
    font-size: @font-size-sm;
    font-weight: 500;
    cursor: pointer;
    transition: all @transition-fast;
    white-space: nowrap;

    &:hover {
      background: @primary-50;
      border-color: @primary-400;
    }

    &:active {
      background: @primary-100;
    }
  }

  &__list {
    max-height: 400px;
    overflow-y: auto;
  }

  &__empty {
    text-align: center;
    padding: @spacing-2xl;
    color: @gray-500;

    p {
      margin: 0;
      font-size: @font-size-sm;
    }

    button {
      background: none;
      border: none;
      font-size: @font-size-sm;
      cursor: pointer;
      text-decoration: underline;
    }
  }

  &__item {
    .flex-start();
    align-items: center;
    gap: @spacing-md;
    padding: @spacing-md @spacing-lg;
    cursor: pointer;
    transition: all @transition-fast;
    border-bottom: 1px solid @gray-100;

    &:last-child {
      border-bottom: none;
    }

    &:hover {
      background: @gray-50;
    }

    &--selected {
      background: @primary-50;
      border-color: @primary-200;

      &:hover {
        background: @primary-100;
      }
    }
  }

  &__item-selection {
    flex-shrink: 0;
  }

  &__item-icon {
    width: 40px;
    height: 40px;
    .flex-center();
    border-radius: @border-radius;
    flex-shrink: 0;
  }

  &__item-info {
    flex: 1;
    min-width: 0;
  }

  &__item-name {
    font-weight: 500;
    color: @gray-900;
    .truncate();
    margin-bottom: 2px;
  }

  &__item-meta {
    font-size: @font-size-xs;
    color: @gray-500;
    .truncate();
  }

  &__item-preview {
    width: 50px;
    height: 30px;
    border-radius: @border-radius;
    overflow: hidden;
    flex-shrink: 0;
    background: @gray-100;
  }

  &__preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  &__info {
    padding: @spacing-md @spacing-lg;
    background: @gray-50;
    border-top: 1px solid @gray-200;

    p {
      margin: 0;
      font-size: @font-size-sm;
      color: @gray-600;
      text-align: center;
    }
  }
}

// Responsive
@media (max-width: 768px) {
  .file-selector {
    &__header {
      flex-direction: column;
      align-items: stretch;
      gap: @spacing-sm;
    }

    &__item {
      padding: @spacing-sm @spacing-md;
    }

    &__item-icon {
      width: 35px;
      height: 35px;
    }

    &__item-name {
      font-size: @font-size-sm;
    }

    &__item-preview {
      width: 40px;
      height: 25px;
    }
  }
}
